From 857c19cc05c8a22bacae9e9997a26a97da570276 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 3 Jun 2017 11:11:22 -0700 Subject: [PATCH] Comment about `Clone` on Context --- src/cargo/core/resolver/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 00b3cdcda..fba3384c2 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -295,12 +295,24 @@ enum GraphNode { Link(PackageId, PackageId), } +// A `Context` is basically a bunch of local resolution information which is +// kept around for all `BacktrackFrame` instances. As a result, this runs the +// risk of being cloned *a lot* so we want to make this as cheap to clone as +// possible. #[derive(Clone)] struct Context<'a> { + // TODO: Both this and the map below are super expensive to clone. We should + // switch to persistent hash maps if we can at some point or otherwise + // make these much cheaper to clone in general. activations: Activations, - resolve_graph: RcList, resolve_features: HashMap>, + + // These are two cheaply-cloneable lists (O(1) clone) which are effectively + // hash maps but are built up as "construction lists". We'll iterate these + // at the very end and actually construct the map that we're making. + resolve_graph: RcList, resolve_replacements: RcList<(PackageId, PackageId)>, + replacements: &'a [(PackageIdSpec, Dependency)], } -- 2.30.2